package com.cattsoft.android.widget;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;

public class CheckBoxActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.check_box);
		observeButton();
	}

	private void observeButton() {
		((CheckBox) findViewById(R.id.CheckBox01)).setOnClickListener(listener);
		((CheckBox) findViewById(R.id.CheckBox02)).setOnClickListener(listener);
		((CheckBox) findViewById(R.id.CheckBox03)).setOnClickListener(listener);
		
	}

	private OnClickListener listener = new OnClickListener() {

		@Override
		public void onClick(View v) {
			CheckBox checkbox = (CheckBox) findViewById(v.getId());
			if (checkbox.isChecked()) {
				list.add(checkbox.getText().toString());
			} else {
				list.remove(checkbox.getText().toString());
			}
			setTitle(list.toString());
		}
	};

	private List<String> list = new ArrayList<String>();

}
